﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace PCS_Linh.lab01
{
    class Replace
    {
        public void run()
        { 
            //nhap so phan tu cua mang
            Console.Write("nhap so phan tu cua mang: ");
            int n = Convert.ToInt32(Console.ReadLine());

            //nhap so
            int [] a = new int[n];
            for (int i = 0; i < n; i++)
            {
                Console.Write("a[{0}]: ", i);
                a[i] = Convert.ToInt32(Console.ReadLine());
            }

            Console.Write("Phan tu trong mang: ");
            for (int i = 0; i < n; i++)
            {
                Console.Write(a[i] + " ");
            }
            Console.WriteLine();

            //nhap bien b
            Console.Write("Nhap bien b: ");
            int b = Convert.ToInt32(Console.ReadLine());

            Console.Write("Nhap bien c: ");
            int c = Convert.ToInt32(Console.ReadLine());

            for (int i = 0; i < n; i++)
            {
                if (a[i] == b)
                {
                    a[i] = c;
                }
            }

            //in ra
            Console.Write("mang sau khi lam lai: ");
            for (int i = 0; i < n; i++)
            {
                Console.Write(a[i] + " ");
            }
        }
    }
}
